const Mock = require('mockjs')

const Random = Mock.Random

let Result = {
    code: 200,
    msg: 'ok',
    data: null
}

//rurl记得加 "/"
Mock.mock('/AuthCode', 'get', () => {
    Result.data = {
        token: Random.string(32),
        authCodeImg: Random.dataImage('120x40', 'p7n5')
    }
    return Result
})

Mock.mock('/login', 'post', () => {
    //mock无法在header中传入jwt
    Result.code = 200
    Result.msg = "ok"
    return Result
})

Mock.mock('/sys/getUserInfo', 'get', () => {
    //mock无法在header中传入jwt
    Result.code = 200
    Result.msg = "ok"
    Result.data = {
        id: "1",
        userName: "管理员",
        avatar: "https://portrait.gitee.com/uploads/avatars/user/3210/9630159_kimia_1629792887.png!avatar30"
    }
    return Result
})

Mock.mock('/exit', 'get', () => {
    //mock无法在header中传入jwt
    Result.code = 200
    Result.msg = "ok"

    return Result
})

/**
 * 判定权限
 */
Mock.mock('/sys/menu/nav', 'get', () => {

    let nav = [
        {
            title: '系统管理',
            name: 'SysMange',
            icon: 'el-icon-s-operation',
            component: '',
            path: '',
            children: [
                {
                    title: '显示管理',
                    name: 'SysScreen',
                    icon: 'el-icon-s-custom',
                    component: 'sys/Screen',
                    path: '/sys/screen',
                    children: []
                },
                {
                    title: '修改密码',
                    name: 'SysPersonalCenter',
                    icon: 'el-icon-s-custom',
                    component: 'sys/PersonalCenter',
                    path: '/sys/personalCenter',
                    children: []
                }
            ]
        }
    ]
    let authority = ['sys:user:list', 'sys:user:save']
    //mock无法在header中传入jwt
    Result.code = 200
    Result.msg = "ok"
    Result.data = {
        nav: nav,
        authority: authority
    }
    return Result
})

Mock.mock(RegExp('/sys/user/getUserList*'), 'get', () => {
    Result.data = {
        records: [{
            id: 1,
            img: 'http://lyly360.oss-cn-shenzhen.aliyuncs.com/file7RkrBD7EMP.jpg',
            name: '云问诊',
            link: 'https://wx021dac92168818f3.wu.guahao.com/ihospital/consult/more',
            userId: '1',
            status: 1,
            createTime: '2021-12-06 16:39:00',
            updateTime: '2021-12-06 16:39:00'
        }, {
            id: 2,
            img: 'http://lyly360.oss-cn-shenzhen.aliyuncs.com/fileA48eKwZf6e.jpg',
            name: '鹰瞳',
            link: '',
            userId: '1',
            status: 0,
            createTime: '2021-12-06 16:40:00',
            updateTime: '2021-12-06 16:40:00'
        }],
        size: 2,
        total: 1,
        current: 1

    }
    return Result
})

Mock.mock(RegExp('/sys/user/getUserInfo/*'), 'get', () => {
    Result.data = {
        id: 1,
        name: '云问诊',
        img: 'http://lyly360.oss-cn-shenzhen.aliyuncs.com/file7RkrBD7EMP.jpg',
        link: 'https://wx021dac92168818f3.wu.guahao.com/ihospital/consult/more',
        status: 1
    }
    return Result
})

Mock.mock(RegExp('/sys/user/delete/*'), 'post', () => {
    return Result
})
Mock.mock('/sys/user/update', 'post', () => {
    Result.data = "修改成功"
    return Result
})

Mock.mock('/sys/user/save', 'post', () => {
    Result.data = '新增成功'
    return Result
})

Mock.mock(RegExp('/sys/user/restPass'), 'post', () => {
    Result.data = '重置成功'
    return Result
})


